/**
 * 部分组件的类型定义
 */
import type { SelectOptionItem } from "./antd";
import type { SelectProps, TreeSelectProps, DatePickerProps, TableColumnProps, ButtonProps } from "ant-design-vue";
import type { TableRecord } from "/@/api/models";
import type { PermissionCode } from "/@/api/permissionCode";
import type { OperPermissionType, RoleUserItem } from "/@/api/aiot/role/models";
import type { UserItem } from "/@/api/aiot/organization/models";
import { InjectionKey, Ref } from "vue";
/**
 * labelSelect
 */
export enum LabelSelectType {
  rangePicker = "rangePicker",
  datePicker = "datePicker",
}
/**
 * SearchForm
 */
export interface SearchFormProps {
  title?: string;
  selectData?: SelectItem[];
  keyword?: string;
  keywordSearchData?: (string | KeywordSearchItem)[];
  hideSelectData?: SelectItem[];
  columns?: TableColumnProps<TableRecord>[];
  requiredKeys?: string[];
  addBtnText?: string;
  addBtnDisabled?: boolean;
  addBtnLoading?: boolean;
  addBtnPermissionCode?: PermissionCode;
  addBtnOperType?: OperPermissionType;
  showAddBtn?: boolean;
  delBtnText?: string;
  delBtnProps?: ButtonProps;
  delBtnPermissionCode?: PermissionCode;
  delBtnOperType?: OperPermissionType;
  delBtnDisabledMes?: string | null;
  size?: ButtonProps["size"];
  maxlength?: number;
}

export interface SelectItem {
  label: string;
  value?: string | number | null;
  options?: SelectOptionItem[];
  key: string;
  props?: SelectProps & TreeSelectProps & DatePickerProps;
  isTreeSelect?: boolean;
  selectType?: LabelSelectType;
  containerWidth?: number;
}

export interface KeywordSearchItem {
  key: string;
  label: string;
}

export const SearchFormKeywordKey: InjectionKey<Ref<string>> = Symbol();
/**
 * UserSelect
 */
export interface UserSelectExpose {
  reload: () => Promise<void>;
  reset: () => void;
  getSelecedUser: () => UserItem[];
  toggleLoading: (isLoading: boolean) => void;
}
export interface EquipmentTypeSelectExpose {
  reload: () => Promise<void>;
  reset: () => void;
  getSelecedEquipmentType: () => UserItem[];
}

// 上传附件业务类型
export enum BizType {
  iot = "iot",
}
// 上传附件存储类型
export enum StorageType {
  local = "LOCAL",
  fastdfs = "FAST_DFS",
  minio = "MIN_IO",
  alioss = "ALI_OSS",
  qiniuoss = "QINIU_OSS",
  hwoss = "HW_OSS",
}

export interface UserListExpose {
  getData: (params?: { allData: RoleUserItem[]; keyword?: string }) => RoleUserItem[];
}

export interface SearchFormExpose {
  clearKeyword: () => void;
}

export interface DetailItem {
  label: string;
  value?: string;
  slotName?: string;
}

export interface VisitModalOptions {
  workOrderId?: string;
  workOrderComplaintId?: string;
  workOrderVisitRecordType: "NORMAL" | "COMPLAINT";
}
export interface WorkOrdersOperations {
  workOrderId?: string;
  projectId?: string;
}
export interface CancelApplyModalOptions {
  workOrderId?: string;
  serviceOrderId?: string;
}

export interface SelectableItem {
  label: string;
  value: string | number;
  selected?: boolean;
}

export enum TimeDimension {
  day = "day",
  week = "week",
  month = "month",
  quarter = "quarter",
  year = "year",
}

export interface ConfigurationShowOptions {
  projectId: string;
}
